home *** CD-ROM | disk | FTP | other *** search
- /*
- * pflags.c - routines to set processing flags
- */
-
- #include "RevRdist.h"
- #include "TransSkelProto.h"
-
- static DialogPtr pfDialog;
-
- static void pfEvent (Integer, EventRecord *);
- static void pfClose (void);
- static void pfClobber (void);
- static void pfGetFlags (void);
- static void pfSaveFlags (void);
- static void pfWatch (void);
-
- /*
- *=========================================================================
- * setFlags () - set flags via modeless dialog
- * entry: SkelInit called, but not SkelMain
- * exit: Flags set
- *=========================================================================
- */
- void
- setFlags ()
- {
- register Integer itemNo; /* index to dialog items */
- Integer itemType; /* for GetDItem call */
- Handle item; /* " */
- Rect r; /* " */
- Integer val; /* value of individual flag bits */
-
- pfDialog = GetNewDialog (RSRC_BASE+WIND_FLAGS, nil, (WindowPtr) -1L);
- if (pfDialog == nil)
- return;
- SkelDialog (pfDialog, (vProcPtr)pfEvent, (vProcPtr)pfClose, (vProcPtr)pfClobber);
- /*
- * Preset check boxes based on current Flag bit settings
- */
- for (itemNo = 3; itemNo < 3 + 31; itemNo++)
- {
- itemType = -1;
- GetDItem (pfDialog, itemNo, &itemType, &item, &r);
- if (itemType == (chkCtrl | ctrlItem))
- {
- val = (Flags >> (itemNo - 3)) & 1;
- SetCtlValue ((ControlHandle) item, val);
- }
- }
- ShowWindow ((WindowPtr) pfDialog);
- SkelBackground (pfWatch);
- SkelMain ();
- }
-
-
-
- /*
- *=========================================================================
- * pfClobber () - get rid of the flags dialog resources
- *=========================================================================
- */
- void
- pfClobber ()
- {
- if (pfDialog)
- DisposDialog (pfDialog);
- pfDialog = nil;
- SkelWhoa ();
- }
-
-
- /*
- *=========================================================================
- * pfClose () - exit the flags dialog
- * exit: Flags set based on final control setting in dialog
- *=========================================================================
- */
- void
- pfClose ()
- {
- pfGetFlags ();
- SkelRmveDlog (pfDialog);
- }
-
-
- /*
- *=========================================================================
- * pfEvent (itemNo, theEvent) - handle events in flags dialog
- * entry: itemNo = the item number in dialog
- * theEvent = ptr to event record significant to dialog
- *=========================================================================
- */
- void
- pfEvent (itemNo, theEvent)
- Integer itemNo;
- EventRecord * theEvent;
- {
- Integer itemType; /* dialog item type */
- Handle item; /* dialog item structure */
- Rect r; /* needed for GetDItem */
- Integer val; /* control value */
- Longint l; /* temp long value */
-
- if (itemNo == 1)
- {
- /*
- * Okay button pushed, close dialog
- */
- pfClose ();
- return;
- }
- if (itemNo == 2)
- {
- /*
- * Save button pushed
- */
- pfGetFlags ();
- pfSaveFlags ();
- return;
- }
- /*
- * The only other thing we are interested in is mouse downs in
- * controls
- */
- if (theEvent->what == mouseDown && itemNo > 2)
- {
- itemType = -1;
- GetDItem (pfDialog, itemNo, &itemType, &item, &r);
- if (itemType == (chkCtrl | ctrlItem))
- {
- val = GetCtlValue ((ControlHandle) item);
- SetCtlValue ((ControlHandle) item, !val);
- }
- }
- }
-
-
-
- /*
- *=========================================================================
- * pfGetFlags() - set Flags based on current dialog checkboxes
- * entry: pfDialog set
- * exit: Flags updated
- *=========================================================================
- */
- static void
- pfGetFlags (void)
- {
- Integer itemNo; /* dialog item number */
- Integer itemType; /* dialog item type */
- Handle item; /* dialog item */
- Rect r; /* needed for GetDItem */
- Integer val;
-
- Flags = 0;
- for (itemNo = 3; itemNo < 3 + 31; itemNo++)
- {
- itemType = -1;
- GetDItem (pfDialog, itemNo, &itemType, &item, &r);
- if (itemType == (chkCtrl | ctrlItem))
- {
- val = GetCtlValue ((ControlHandle) item);
- Flags |= val << (itemNo - 3);
- }
- }
- }
-
-
- /*
- *=========================================================================
- * pfSaveFlags() - modify RevRdist processing flags resource
- * entry: Flags = new value for processing flags resource
- * Ap_refNum = refNum of application resource fork
- * exit: resource updated
- *=========================================================================
- */
- static void
- pfSaveFlags (void)
- {
- Handle h; /* ptr to flags resource */
- Integer oldres; /* resource refnum */
-
- oldres = CurResFile();
- UseResFile (Ap_refNum);
- h = Get1Resource (TYPE_LONG, FLAG_PARM);
- if (h)
- {
- if (GetHandleSize (h) >= sizeof (Flags))
- {
- BlockMove ((Ptr) &Flags, *h, sizeof (Flags));
- ChangedResource (h);
- WriteResource (h);
- }
- ReleaseResource (h);
- }
- UseResFile (oldres);
- }
-
- /*
- *=========================================================================
- * pfWatch () - watch for Quit
- *=========================================================================
- */
- void
- pfWatch ()
- {
- if (Quit)
- {
- SkelBackground (nil);
- pfClose ();
- }
- }
-